package com.demo.page9101.controller.bottom;

import com.demo.common.entity.ColumnManagement;
import com.demo.common.entity.CompanyDetails;
import com.demo.common.entity.MediaCoverage;
import com.demo.common.entity.Meta;
import com.demo.page9101.feign.bottom.BottomFeign;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 底部小标
 * 作者：张兴然
 * 分配任务：张改
 * 插入数据：贾冠博
 * 接口文档：贾冠博
 */
@RestController
public class BottomController {

    @Resource
    private BottomFeign bottomFeign;

    @GetMapping("/companyDetails")
    public Map selectCompany(){

        Map<String,Object> map = new HashMap<>();
        //查询公司详细信息
        CompanyDetails companyDetails = bottomFeign.selectCompany();
        //查询媒体报告
        List<MediaCoverage> mediaCoverages = bottomFeign.selectMedia();
        //查询底部小标
        List<ColumnManagement> columnManagements = bottomFeign.selectColumn();

        map.put("媒体报告",mediaCoverages);
        map.put("底部信息",companyDetails);
        map.put("底部小标",columnManagements);
        if(companyDetails!=null && mediaCoverages.size()>0 && columnManagements.size()>0){
            map.put("meta", new Meta("获取成功", "200"));
        }
        else {
            map.put("meta", new Meta("获取失败", "404"));
        }


        return map;
    }

}
